package com.oss.controller.system;

import com.oss.dto.system.GetFilePathDto;
import com.oss.util.FileUtilCustom;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;

@RestController
@RequestMapping("/fileController")
public class FileController {

    @PostMapping("/loadFile")
    public void loadFile(HttpServletResponse response, @RequestBody GetFilePathDto dto) throws Exception {
        File file = new File(dto.getPath());
        FileUtilCustom.downloadFileByPath(dto.getPath(),file.getName(),response);
    }
}